# -*- coding:utf-8 -*-

# PAGE_SIZE = 10


class MyPaging(object):
    """
    分页工具类
    """

    def getPage(self, total_count, page_index, page_size, info_list):
        """
        获取分页数据
        :param total_count: 记录总条数
        :param page_index: 获取哪一页数据
        :param page_size: 每页记录数
        :param info_list: 所有记录列表
        :return: list
        """
        PAGE_SIZE = page_size
        if (page_index * PAGE_SIZE) < total_count:
            start = (page_index - 1) * PAGE_SIZE
            end = page_index * PAGE_SIZE
            list0 = info_list[start: end]
        else:
            start = (page_index - 1) * PAGE_SIZE
            list0 = info_list[start:]

        return list0
